/*
 * Copyright © 2011 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners. 
 * See LICENSE.TXT for license information.
 */ 

package com.nokia.example.wordpress;

import com.nokia.example.wordpress.views.ViewMaster;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;

/**
 * Wordpress midlet. 
 */
public class WordpressMidlet extends MIDlet implements CommandListener {

    private static WordpressMidlet self;
    private Display display = null;
    private ViewMaster viewMaster = ViewMaster.getInstance();

    public WordpressMidlet() {
        self = this;
        display = Display.getDisplay(this);
        // Set up the first view of the application.
        display.setCurrent(viewMaster);
    }

    public void startApp() {
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        display = null;
        viewMaster = null;
    }

    /**
     * Menu actions triggered by Forms
     * @param com Triggered command
     * @param disp
     */
    public void commandAction(Command com, Displayable disp) {
    }

    public static WordpressMidlet getInstance() {
        return self;
    }

    /**
     * Exit application, used from options menu and keyhandlers.
     */
    public void commandExit() {
        System.out.println("commandExit()");
        destroyApp(true);
        notifyDestroyed();
    }
}

